import React from 'react'
import { useLocation, useParams } from 'react-router-dom';
import qs from 'qs';

export default function List() {
  const location = useLocation()
  const { user } = qs.parse(location.search.split("?")[1])
  const state = location.state

  console.log(useParams());
  const { id } = useParams();
  return (
    <div>
      <p>用户名是{user} 编号是:{id}</p>
      <ul>
        {
          state.map(item => {
            return <li key={item.id}>{item.name}</li>
          })
        }
      </ul>
    </div>
  )
}
